package com.ruoyi.kong.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.kong.entity.KongEntity;
import com.ruoyi.kong.entity.KongSni;
import com.ruoyi.kong.service.IKongSniService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/kong/sni")
public class KongSniController extends BaseController {

    @Autowired
    private IKongSniService kongSniService;

    @GetMapping("/list")
    public TableDataInfo getSnis(){
        startPage();
        KongEntity<KongSni> snis = kongSniService.snis();
        return getDataTable(snis.getData());
    }

    @GetMapping("/get/{id}")
    public AjaxResult getSniById(@PathVariable("id") String id){
        KongSni kongSni = kongSniService.sniById(id);
        return AjaxResult.success(kongSni);
    }

    @PostMapping("/add")
    public AjaxResult addSni(@RequestBody KongSni sni){
        KongSni kongSni = kongSniService.addSni(sni);
        return AjaxResult.success(kongSni);
    }
    @PostMapping("/update/{id}")
    public AjaxResult updateSni(@PathVariable("id") String id,@RequestBody KongSni sni){
        KongSni kongSni = kongSniService.updateSni(id,sni);
        return AjaxResult.success(kongSni);
    }

    @PostMapping("/delete/{id}")
    public AjaxResult deleteSni(@PathVariable("id") String id){
        kongSniService.deleteSni(id);
        return success();
    }










}
